package com.recruit.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.recruit.common.dto.shift.CreateOrUpdateShiftDTO;
import com.recruit.common.mapper.ShiftMapper;
import com.recruit.common.model.ShiftDO;
import com.recruit.common.service.ShiftService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  轮播图-服务实现类
 * </p>
 *
 * @author Eval
 * @since 2022-04-04
 */
@Service
public class ShiftServiceImpl extends ServiceImpl<ShiftMapper, ShiftDO> implements ShiftService {

    @Resource
    private ShiftMapper shiftMapper;

    @Override
    public boolean createShift(CreateOrUpdateShiftDTO validator) {
        ShiftDO  shiftDO = new ShiftDO();
        shiftDO.setTitle(validator.getTitle());
        shiftDO.setUrl(validator.getUrl());
        shiftDO.setSt(validator.getSt());
        return shiftMapper.insert(shiftDO) > 0;
    }

    @Override
    public boolean updateShift(ShiftDO shiftDO, CreateOrUpdateShiftDTO validator) {
        shiftDO.setTitle(validator.getTitle());
        shiftDO.setUrl(validator.getUrl());
        shiftDO.setSt(validator.getSt());
        return shiftMapper.updateById(shiftDO) > 0;
    }

    @Override
    public boolean deleteById(Integer id) {
        return shiftMapper.deleteById(id) > 0;
    }

    @Override
    public List<ShiftDO> getAll() {
        return shiftMapper.selectList(null);
    }

    @Override
    public List<ShiftDO> show() {
        return shiftMapper.show();
    }
}
